home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htgroup.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  5.7 KB  |  188 lines

  1. /*                                    GROUP FILE ROUTINES
  2.                                              
  3.  */
  4.  
  5. #ifndef HTGROUP_H
  6. #define HTGROUP_H
  7.  
  8. #include "HTUtils.h"
  9. #include "HTList.h"
  10.  
  11. #ifdef SHORT_NAMES
  12. #define HTAApGrD        HTAA_parseGroupDef
  13. #define HTAArGrR        HTAA_resolveGroupReferences
  14. #define HTAApGrD        HTAA_printGroupDef
  15. #define HTAAGD_d        GroupDef_delete
  16. #define HTAAuIIG        HTAA_userAndInetInGroup
  17. #endif /* SHORT_NAMES */
  18.  
  19. typedef HTList GroupDefList;
  20. typedef HTList ItemList;
  21.  
  22. typedef struct {
  23.     char *      group_name;
  24.     ItemList *  item_list;
  25. } GroupDef;
  26.  
  27.  
  28. /*
  29. ** Access Authorization failure reasons
  30. */
  31. typedef enum {
  32.     HTAA_OK,            /* 200 OK                               */
  33.     HTAA_OK_GATEWAY,    /* 200 OK, acting as a gateway          */
  34.     HTAA_NO_AUTH,       /* 401 Unauthorized, not authenticated  */
  35.     HTAA_NOT_MEMBER,    /* 401 Unauthorized, not authorized     */
  36.     HTAA_IP_MASK,       /* 403 Forbidden by IP mask             */
  37.     HTAA_BY_RULE,       /* 403 Forbidden by rule                */
  38.     HTAA_NO_ACL,        /* 403 Forbidden, ACL non-existent      */
  39.     HTAA_NO_ENTRY,      /* 403 Forbidden, no ACL entry          */
  40.     HTAA_SETUP_ERROR,   /* 403 Forbidden, server setup error    */
  41.     HTAA_DOTDOT,        /* 403 Forbidden, URL with /../ illegal */
  42.     HTAA_HTBIN,         /* 403 Forbidden, /htbin not enabled    */
  43.     HTAA_NOT_FOUND      /* 404 Not found, or read protected     */
  44. } HTAAFailReasonType;
  45.  
  46. /*
  47.  
  48. Group definition grammar
  49.  
  50.   string
  51.                          "sequence of alphanumeric characters"
  52.                          
  53.   user_name
  54.                          string
  55.                          
  56.   group_name
  57.                          string
  58.                          
  59.   group_ref
  60.                          group_name
  61.                          
  62.   user_def
  63.                          user_name | group_ref
  64.                          
  65.   user_def_list
  66.                            user_def { ',' user_def }
  67.                          
  68.   user_part
  69.                          user_def | '(' user_def_list ')'
  70.                          
  71.   templ
  72.                          
  73.                          "sequence of alphanumeric characters and '*'s"
  74.                          
  75.   ip_number_mask
  76.                          templ '.' templ '.' templ '.' templ
  77.                          
  78.   domain_name_mask
  79.                          templ { '.' templ }
  80.                          
  81.   address
  82.                          
  83.                          ip_number_mask | domain_name_mask
  84.                          
  85.   address_def
  86.                          
  87.                          address
  88.                          
  89.   address_def_list
  90.                          address_def { ',' address_def }
  91.                          
  92.   address_part
  93.                          address_def | '(' address_def_list ')'
  94.                          
  95.   item
  96.                          [user_part] ['@' address_part]
  97.                          
  98.   item_list
  99.                          item { ',' item }
  100.                          
  101.   group_def
  102.                          item_list
  103.                          
  104.   group_decl
  105.                          group_name ':' group_def
  106.                          
  107.   PARSE GROUP DEFINITION
  108.   
  109.  */
  110.  
  111. PUBLIC GroupDef *HTAA_parseGroupDef PARAMS((FILE * fp));
  112. /*
  113.  
  114. Fill in Pointers to referenced Group Definitions in a Group Definition
  115.  
  116.    References to groups (by their name) are resolved from group_def_list and pointers to
  117.    those structures are added to group_def.
  118.    
  119.  */
  120.  
  121. PUBLIC void HTAA_resolveGroupReferences PARAMS((GroupDef *     group_def,
  122.                                                 GroupDefList * group_def_list));
  123. /*
  124.  
  125. Read Group File (and do caching)
  126.  
  127.    If group file is already in cache returns a pointer to previously read group definition
  128.    list.
  129.    
  130.  */
  131.  
  132. PUBLIC GroupDefList *HTAA_readGroupFile PARAMS((CONST char * filename));
  133. /*
  134.  
  135. Delete Group Definition
  136.  
  137.    Groups in cache should never be freed by this function. This should only be used to
  138.    free group definitions read by HTAA_parseGroupDef.
  139.    
  140.  */
  141.  
  142. PUBLIC void GroupDef_delete PARAMS((GroupDef * group_def));
  143. /*
  144.  
  145. Print Out Group Definition (for trace purposes)
  146.  
  147.  */
  148.  
  149. PUBLIC void HTAA_printGroupDef PARAMS((GroupDef * group_def));
  150. /*
  151.  
  152. Does a User Belong to a Given Set of Groups
  153.  
  154.    This function checks both the username and the internet address.
  155.    
  156.  */
  157.  
  158. /* PUBLIC                                       HTAA_userAndInetInGroup()
  159. **              CHECK IF USER BELONGS TO TO A GIVEN GROUP
  160. **              AND THAT THE CONNECTION COMES FROM AN
  161. **              ADDRESS THAT IS ALLOWED BY THAT GROUP
  162. ** ON ENTRY:
  163. **      group           the group definition structure.
  164. **      username        connecting user.
  165. **      ip_number       browser host IP number, optional.
  166. **      ip_name         browser host IP name, optional.
  167. **                      However, one of ip_number or ip_name
  168. **                      must be given.
  169. ** ON EXIT:
  170. **      returns         HTAA_IP_MASK, if IP address mask was
  171. **                      reason for failing.
  172. **                      HTAA_NOT_MEMBER, if user does not belong
  173. **                      to the group.
  174. **                      HTAA_OK if both IP address and user are ok.
  175. */
  176. PUBLIC HTAAFailReasonType HTAA_userAndInetInGroup PARAMS((GroupDef * group,
  177.                                                           char *     username,
  178.                                                           char *     ip_number,
  179.                                                           char *     ip_name));
  180. /*
  181.  
  182.  */
  183.  
  184. #endif /* not HTGROUP_H */
  185. /*
  186.  
  187.    End of file HTGroup.h.  */
  188.